package com.luo.gmall.sms.controller;

import java.util.List;

import com.luo.gmall.sms.vo.ItemSaleVo;
import com.luo.gmall.sms.vo.SmsSaleVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import com.luo.gmall.sms.entity.SkuBoundsEntity;
import com.luo.gmall.sms.service.SkuBoundsService;
import com.luo.gmall.common.bean.PageResultVo;
import com.luo.gmall.common.bean.ResponseVo;
import com.luo.gmall.common.bean.PageParamVo;

/**
 * 商品spu积分设置
 *
 * @author zoro
 * @email 1160848022@qq.com
 * @date 2021-11-01 20:20:09
 */
@Api(tags = "商品spu积分设置 管理")
@RestController
@RequestMapping("sms/skubounds")
public class SkuBoundsController {

    @Autowired
    private SkuBoundsService skuBoundsService;


    /**
     * 6.根据skuId查询营销信息
     */
    @GetMapping("sales/{skuId}")
    public ResponseVo<List<ItemSaleVo>> queryListSalesBySkuId(@PathVariable Long skuId) {
        List<ItemSaleVo> itemSaleVos = skuBoundsService.queryListSalesBySkuId(skuId);
        return ResponseVo.ok(itemSaleVos);
    }


    @PostMapping("sale")
    public ResponseVo saveSmsSaleVo(@RequestBody SmsSaleVo smsSaleVo) {
        skuBoundsService.saveSmsSaleVo(smsSaleVo);
        return ResponseVo.ok();

    }

    /**
     * 列表
     */
    @GetMapping
    @ApiOperation("分页查询")
    public ResponseVo<PageResultVo> querySkuBoundsByPage(PageParamVo paramVo) {
        PageResultVo pageResultVo = skuBoundsService.queryPage(paramVo);

        return ResponseVo.ok(pageResultVo);
    }


    /**
     * 信息
     */
    @GetMapping("{id}")
    @ApiOperation("详情查询")
    public ResponseVo<SkuBoundsEntity> querySkuBoundsById(@PathVariable("id") Long id) {
        SkuBoundsEntity skuBounds = skuBoundsService.getById(id);

        return ResponseVo.ok(skuBounds);
    }

    /**
     * 保存
     */
    @PostMapping
    @ApiOperation("保存")
    public ResponseVo<Object> save(@RequestBody SkuBoundsEntity skuBounds) {
        skuBoundsService.save(skuBounds);

        return ResponseVo.ok();
    }

    /**
     * 修改
     */
    @PostMapping("/update")
    @ApiOperation("修改")
    public ResponseVo update(@RequestBody SkuBoundsEntity skuBounds) {
        skuBoundsService.updateById(skuBounds);

        return ResponseVo.ok();
    }

    /**
     * 删除
     */
    @PostMapping("/delete")
    @ApiOperation("删除")
    public ResponseVo delete(@RequestBody List<Long> ids) {
        skuBoundsService.removeByIds(ids);

        return ResponseVo.ok();
    }

}
